<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/calendar.js"></script>
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var startDay = document.getElementById("startDay");
		var endDay = document.getElementById("endDay");
		var startDate = document.getElementById("startDate");
		var endDate = document.getElementById("endDate");
		
		
		if(startDay.value != ""){
			if(endDay.value == ""){
				alert("请输入完整账龄区间！");
				return false;
			}else{
				var n1 = "";
				var n2 = "";
				n1 = Number(startDay.value);
				n2 = Number(endDay.value);
				if(n1 - n2 >= 0){
					alert("开始账龄不能小于等于结束账龄！");
					return false;
				}
			}
		}
		
		if(startDate.value != ""){
			if(endDate.value == ""){
				alert("请输入完整建账日期区间！");
				return false;
			}else{
				var d1 = "";
				var d2 = "";
				d1 = (startDate.value).replace("-","/");
				d2 = (endDate.value).replace("-","/");
				if(Date.parse(d1) - Date.parse(d2) >= 0){
					alert("开始建账日期不能小于等于结束建账日期！");
					return false;
				}
			}
		}
		
		return true;
	}

	function back(){
		var uri = "./contractBackCost.do";
		var sign = "<c:out value='${sign}'/>";
		if(sign == "1"){//返回到应收帐款页面
			uri = "./contractBackCost.do";
		}else if(sign == "2"){//返回到部门应收帐款页面
			uri = "./contractBackCost.do?action=deptBackCostManage";
		}
		window.location.href = uri;
		window.location.target = "main";
	}
	
	function save(){
		if(checkForm()){
			document.exportBackCostForm.action = "./contractBackCost.do?action=exportBackCost";
			document.exportBackCostForm.target = "main";
			document.exportBackCostForm.submit();
			
			var nodes = document.exportBackCostForm.elements;
			for(var i = 0; i < nodes.length; i++){
				var node = document.exportBackCostForm.elements[i];
					node.disabled = true;
			}
			
			document.getElementById("tImport").style.display = "block";
		}
	}
	
	function initPage(){
		if("<c:out value='${result}'/>" == 1){
			alert("查询成功，点击“确定”导出相关记录。");
			document.exportBackCostForm.action = "./contractBackCost.do?action=uploadExportFile";
			document.exportBackCostForm.target = "main";
			document.exportBackCostForm.submit();
			
			var nodes = document.exportBackCostForm.elements;
			for(var i = 0; i < nodes.length; i++){
				var node = document.exportBackCostForm.elements[i];
					node.disabled = false;
			}
			
			document.getElementById("tImport").style.display = "none";
		}
	}
-->
</script>
</head>
<body onload="initPage()">
<form name="exportBackCostForm" action="" method="post">
	<table class="table_frame">
		<tr>
			<td>
				<table class="table_title1">
					<tr>
						<td class="title_lab" colspan="3">
							导出应收帐款
						</td>
					</tr>
					<tr>
						<td align="center" valign="bottom">
							<button class="btn_submit" onclick="save()" hidefocus="true">确定</button>&nbsp;&nbsp;
							<button class="btn_back" onclick="back()" hidefocus="true">取消并返回</button>
						</td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td valign="top">
				<table class="table_title2">
					<tr>
						<td>
							<table id="tImport" class="table_add" style="display: none;">
								<tr>
									<td class="title_top">结果信息</td>
								</tr>
								<tr>
									<td class="" style="height: 50px;"><b>正在查找符合条件的记录，请稍后...</b></td>
								</tr>
							</table>
							
							<table class="table_add">
								<tr>
									<td class="title_top" colspan="2">请输入或选择导出条件：</td>
								</tr>
								<tr>
									<td class="title">财龄：</td>
									<td>
										<input id="startDay" name="startDay" class="input_query" type="text" maxlength="5" value="" onkeyup="onlyNumber(this)"/>&nbsp;--
										<input id="endDay" name="endDay" class="input_query" type="text" maxlength="5" value="" onkeyup="onlyNumber(this)"/>
									</td>
								</tr>
								<tr>
									<td class="title">建账日期：</td>
									<td>
										<input id="startDate" name="startDate" class="input_query" type="text" value="" onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>&nbsp;--
										<input id="endDate" name="endDate" class="input_query" type="text" value="" onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>
									</td>
								</tr>
							</table>
							
							<c:if test="${not empty users}">
							<table class="table_style">
								<tr>
									<td class="title" width="8"></td>
									<td class="title" width="30"><!-- <input type="checkbox"/> -->选择</td>
									<td class="title">姓名</td>
									<td class="title">所属部门</td>
								</tr>
								<c:forEach var="user" items="${users}">
								<tr onmouseover="onmousemoveChange(this,'img${user.id}')" onmouseout="onmouseoutChange(this,'img${user.id}')">
									<td height="16" width="8" align="right"><img id="img${user.id}" src="./images/table_sign2.bmp"></td>
									<td><input id="id" name="id" type="checkbox" value="${user.id}"/></td>
									<td>${user.userName}</td>
									<td>${user.deptName}</td>
								</tr>
								</c:forEach>
							</table>
							</c:if>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<input id="sign" name="sign" type="hidden" value="${sign}"/>
</form>		
</body>
</html>